var util = require("./util"), Reporter = require("./reporter"), MiniLogger = function(e) {
    e && e.pid || util.warn("[arms] pid is a required prop to instatiate MiniLogger");
    var t = this;
    return Reporter.call(t, e), t._health = {
        errcount: 0,
        apisucc: 0,
        apifail: 0
    }, t._initialPage = e.page && util.safetyCall(e.page, [], "" + e.page) || "miniLogger", 
    t.beforeSend = function(e, r) {
        "error" === e ? t._health.errcount++ : "api" === e && t._health[r.success ? "apisucc" : "apifail"]++;
    }, t;
};

MiniLogger.prototype = util.createObject(Reporter.prototype), util.ext(Reporter._root.dftCon, {
    uid: null,
    page: null,
    sendRequest: function() {}
}), util.ext(MiniLogger.prototype, {
    constructor: MiniLogger,
    _super: Reporter,
    onReady: function(e) {
        e();
    },
    sendRequest: function(e, t) {
        if (this.getConfig("debug")) "undefined" != typeof console && console && "function" == typeof console.log && console.log("[arms] [DEBUG MODE] log data", e); else {
            var r = this.getConfig("imgUrl");
            "object" == typeof e && (e = util.serialize(e));
            var i = r + e;
            t && (i += "&post_res=");
            var o = this._conf.sendRequest;
            if ("function" == typeof o) try {
                o(i, t);
            } catch (n) {
                util.warn("[arms] error in sendRequest", n);
            }
        }
    },
    postData: function(e, t) {
        var r = {};
        r[t] = e[t], delete e[t], this.sendRequest(e, r);
    },
    commonInfo: function() {
        return {
            uid: this._conf.uid || ""
        };
    }
});

var singleton = null, generator = function(e) {
    return singleton || (singleton = new MiniLogger(e || {})), singleton;
};

MiniLogger.createExtraInstance = function(e) {
    return new MiniLogger(e);
}, MiniLogger.init = generator, MiniLogger.singleton = generator, MiniLogger._super = Reporter, 
MiniLogger._root = Reporter._root, Reporter.MiniLogger = MiniLogger, module.exports = MiniLogger;